using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using WorkflowProcesses = Scenario.WorkflowEngine.DataModel.WorkflowProcesses;

namespace Scenario.Modeler
{
	/// <summary>
	/// Descrizione di riepilogo per FrmScriptAction.
	/// </summary>
	public class FormScriptAction : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.TextBox txtAction;
		/// <summary>
		/// Variabile di progettazione necessaria.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Button btnSave;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.CheckBox chkNone;

		public WorkflowProcesses.XMLScript xmlScript = null;

		public FormScriptAction()
		{
			//
			// Necessario per il supporto di Progettazione Windows Form
			//
			InitializeComponent();

			//
			// TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent
			//
		}

		public FormScriptAction(string sAction) : this()
		{
			//
			// TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent
			//
			if ( sAction == WorkflowProcesses.XMLScript.NONE_ACTION ) 
			{
				this.chkNone.Checked = true;
			}
			else
			{
				this.chkNone.Checked = false;
				txtAction.Text = sAction;
			}
		}



		/// <summary>
		/// Pulire le risorse in uso.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Codice generato da Progettazione Windows Form
		/// <summary>
		/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
		/// il contenuto del metodo con l'editor di codice.
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.txtAction = new System.Windows.Forms.TextBox();
			this.panel1 = new System.Windows.Forms.Panel();
			this.btnSave = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.chkNone = new System.Windows.Forms.CheckBox();
			this.groupBox1.SuspendLayout();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.chkNone);
			this.groupBox1.Controls.Add(this.txtAction);
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(784, 472);
			this.groupBox1.TabIndex = 2;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Action";
			// 
			// txtAction
			// 
			this.txtAction.Location = new System.Drawing.Point(8, 56);
			this.txtAction.Multiline = true;
			this.txtAction.Name = "txtAction";
			this.txtAction.Size = new System.Drawing.Size(768, 400);
			this.txtAction.TabIndex = 2;
			this.txtAction.Text = "";
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.btnCancel);
			this.panel1.Controls.Add(this.btnSave);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel1.Location = new System.Drawing.Point(0, 475);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(800, 64);
			this.panel1.TabIndex = 3;
			// 
			// btnSave
			// 
			this.btnSave.Location = new System.Drawing.Point(192, 16);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new System.Drawing.Size(144, 32);
			this.btnSave.TabIndex = 5;
			this.btnSave.Text = "Save";
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(392, 16);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(168, 32);
			this.btnCancel.TabIndex = 6;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// chkNone
			// 
			this.chkNone.Location = new System.Drawing.Point(16, 24);
			this.chkNone.Name = "chkNone";
			this.chkNone.Size = new System.Drawing.Size(376, 24);
			this.chkNone.TabIndex = 3;
			this.chkNone.Text = "Set to NONE";
			this.chkNone.CheckedChanged += new System.EventHandler(this.chkNone_CheckedChanged);
			// 
			// FormScriptAction
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.ClientSize = new System.Drawing.Size(800, 539);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.groupBox1);
			this.Name = "FormScriptAction";
			this.Text = "Action";
			this.groupBox1.ResumeLayout(false);
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			xmlScript = new WorkflowProcesses.XMLScript();
			xmlScript.Value =this.txtAction.Text;

			this.Close();
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void chkNone_CheckedChanged(object sender, System.EventArgs e)
		{
			if ( this.chkNone.Checked )
			{
				this.txtAction.Enabled = false;
				this.txtAction.Text = WorkflowProcesses.XMLScript.NONE_ACTION;
			}
			else
				this.txtAction.Enabled = true;
		}
	}
}
